using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the TblConfiguración class.
	/// </summary>
	[Serializable]
	public partial class TblConfiguraciónCollection : ActiveList<TblConfiguración, TblConfiguraciónCollection> 
	{	   
		public TblConfiguraciónCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the tblConfiguración table.
	/// </summary>
	[Serializable]
	public partial class TblConfiguración : ActiveRecord<TblConfiguración>
	{
		#region .ctors and Default Settings
		
		public TblConfiguración()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public TblConfiguración(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public TblConfiguración(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public TblConfiguración(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("tblConfiguración", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
				colvarId.ColumnName = "ID";
				colvarId.DataType = DbType.Int32;
				colvarId.MaxLength = 0;
				colvarId.AutoIncrement = true;
				colvarId.IsNullable = false;
				colvarId.IsPrimaryKey = true;
				colvarId.IsForeignKey = false;
				colvarId.IsReadOnly = false;
				colvarId.DefaultSetting = @"";
				colvarId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarId);
				
				TableSchema.TableColumn colvarUserID = new TableSchema.TableColumn(schema);
				colvarUserID.ColumnName = "UserID";
				colvarUserID.DataType = DbType.Int32;
				colvarUserID.MaxLength = 0;
				colvarUserID.AutoIncrement = false;
				colvarUserID.IsNullable = false;
				colvarUserID.IsPrimaryKey = false;
				colvarUserID.IsForeignKey = false;
				colvarUserID.IsReadOnly = false;
				colvarUserID.DefaultSetting = @"";
				colvarUserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserID);
				
				TableSchema.TableColumn colvarDateX = new TableSchema.TableColumn(schema);
				colvarDateX.ColumnName = "Date";
				colvarDateX.DataType = DbType.DateTime;
				colvarDateX.MaxLength = 0;
				colvarDateX.AutoIncrement = false;
				colvarDateX.IsNullable = false;
				colvarDateX.IsPrimaryKey = false;
				colvarDateX.IsForeignKey = false;
				colvarDateX.IsReadOnly = false;
				colvarDateX.DefaultSetting = @"";
				colvarDateX.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateX);
				
				TableSchema.TableColumn colvarDesign = new TableSchema.TableColumn(schema);
				colvarDesign.ColumnName = "Design";
				colvarDesign.DataType = DbType.Int32;
				colvarDesign.MaxLength = 0;
				colvarDesign.AutoIncrement = false;
				colvarDesign.IsNullable = true;
				colvarDesign.IsPrimaryKey = false;
				colvarDesign.IsForeignKey = false;
				colvarDesign.IsReadOnly = false;
				colvarDesign.DefaultSetting = @"";
				colvarDesign.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDesign);
				
				TableSchema.TableColumn colvarPage = new TableSchema.TableColumn(schema);
				colvarPage.ColumnName = "Page";
				colvarPage.DataType = DbType.String;
				colvarPage.MaxLength = 50;
				colvarPage.AutoIncrement = false;
				colvarPage.IsNullable = true;
				colvarPage.IsPrimaryKey = false;
				colvarPage.IsForeignKey = false;
				colvarPage.IsReadOnly = false;
				colvarPage.DefaultSetting = @"";
				colvarPage.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPage);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("tblConfiguración",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("Id")]
		public int Id 
		{
			get { return GetColumnValue<int>("ID"); }

			set { SetColumnValue("ID", value); }

		}

		  
		[XmlAttribute("UserID")]
		public int UserID 
		{
			get { return GetColumnValue<int>("UserID"); }

			set { SetColumnValue("UserID", value); }

		}

		  
		[XmlAttribute("DateX")]
		public DateTime DateX 
		{
			get { return GetColumnValue<DateTime>("Date"); }

			set { SetColumnValue("Date", value); }

		}

		  
		[XmlAttribute("Design")]
		public int? Design 
		{
			get { return GetColumnValue<int?>("Design"); }

			set { SetColumnValue("Design", value); }

		}

		  
		[XmlAttribute("Page")]
		public string Page 
		{
			get { return GetColumnValue<string>("Page"); }

			set { SetColumnValue("Page", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int varUserID,DateTime varDateX,int? varDesign,string varPage)
		{
			TblConfiguración item = new TblConfiguración();
			
			item.UserID = varUserID;
			
			item.DateX = varDateX;
			
			item.Design = varDesign;
			
			item.Page = varPage;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varId,int varUserID,DateTime varDateX,int? varDesign,string varPage)
		{
			TblConfiguración item = new TblConfiguración();
			
				item.Id = varId;
				
				item.UserID = varUserID;
				
				item.DateX = varDateX;
				
				item.Design = varDesign;
				
				item.Page = varPage;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string Id = @"ID";
			 public static string UserID = @"UserID";
			 public static string DateX = @"Date";
			 public static string Design = @"Design";
			 public static string Page = @"Page";
						
		}

		#endregion
	}

}

